package Server.Dwc.fish;

import java.util.HashMap;
import java.util.Map;
import java.util.Vector;

import Server.Model.Base.SHMUser;
import Server.Model.Hall.dthall;
import redis.protocal.DbInfoMgr;

public class FishLogic {
	private int MAX_USER_SIZE = 1000;
	private static FishLogic _instance = null;
	public static FishLogic getInstance(){
		if(_instance == null)
			_instance = new FishLogic();
		return _instance;
	}
	long m_LastDealTime;
	long m_LastUpdateTime;
	public Map<Integer,FishTable> m_mapUID2Table = new HashMap<Integer,FishTable>();
	private int[] vecAllUser;
	private int[] vecAllUserHeartTime;
	public void Init(){
		//初始化配置，鱼桌子等等
		
	}
	public int FindTable(int _Uid){
		return 0;
	}
	public int OnUserSit(int _Uid){
		return 0;
	}
	public int OnUserStandUp(int _Uid){
		return 0;
	}
	public void Handle_onHeart(int _Uid,String[] vecArg){
		
	}
	public void Handle_onJoin(int _Uid,String[] vecArg){
		
	}
	public void Handle_onLeave(int _Uid,String[] vecArg){
		
	}
	public void OnDeal(float dt){
		
	}
	/*
	public void Handle_onJoinTable(int _Uid,String[] vecArg){
		if(vecArg.length < 2)
			return;
		int iBase = Integer.parseInt(vecArg[1]);
		if(iBase < 10){
			iBase = 1;
		}else if(iBase < 30){
			iBase = 10;
		}else if(iBase < 100){
			iBase = 30;
		}else if(iBase < 300){
			iBase = 100;
		}else if(iBase < 1000){
			iBase = 300;
		}else if(iBase < 10000){
			iBase = 1000;
		}else if(iBase < 50000){
			iBase = 10000;
		}else{
			iBase = 1;
		}
		//倍场判断，现在直接加入房间
		this.OnUserSit(_Uid);
		
		SUBCMD_S_JoinTable cmd = new SUBCMD_S_JoinTable();
		cmd.m_lUid = _Uid;
		cmd.m_iRoomId = this.GetID();
		cmd.m_iBase = iBase;
		for(int wChairID = 0;wChairID < 4;wChairID++){
			if(m_pIUserItem[wChairID].dwUserID > 0 && m_pIUserItem[wChairID].cannonLevel < 60){
				SHMUser user = dthall.getInstance().getUserInfo(m_pIUserItem[wChairID].dwUserID);
				if(user != null){
					int maxcannonlevel = DbInfoMgr.getInstance().getUserControlIntInfo(String.valueOf(m_pIUserItem[wChairID].dwUserID),"fishCannonLevel");
					if(maxcannonlevel < 10){
						maxcannonlevel = 10;
					}
					if(maxcannonlevel > 48){
						maxcannonlevel = 48;
					}
					DbInfoMgr.getInstance().setUserControlInfo(String.valueOf(m_pIUserItem[wChairID].dwUserID), "fishCannonLevel",String.valueOf(maxcannonlevel));
					m_pIUserItem[wChairID].cannonLevel = maxcannonlevel;
					
					
					if(this.m_iBase == 1){
						if(_Uid == m_pIUserItem[wChairID].dwUserID && m_pIUserItem[wChairID].cannonLevel == 1){
							m_pIUserItem[wChairID].cannonLevel = maxcannonlevel;
						}
						if(m_pIUserItem[wChairID].cannonLevel > 26){
							m_pIUserItem[wChairID].cannonLevel = 26;
						}
					}
					
					if(this.m_iBase == 30){
						if(m_pIUserItem[wChairID].cannonLevel < 14){
							m_pIUserItem[wChairID].cannonLevel = 14;
						}
					}
					cmd.m_seatInfo[wChairID].m_lUid = m_pIUserItem[wChairID].dwUserID;
					cmd.m_seatInfo[wChairID].m_iSeatId = wChairID + 1;
					cmd.m_seatInfo[wChairID].m_iVipLevel = DbInfoMgr.getInstance().getUserControlIntInfo(String.valueOf(_Uid), "fishVipLevel");
					cmd.m_seatInfo[wChairID].m_iCoin = user.getCoin(0);
					cmd.m_seatInfo[wChairID].m_iGem = user.getGem(0);
					cmd.m_seatInfo[wChairID].m_iCannonAvatar = DbInfoMgr.getInstance().getUserControlIntInfo(String.valueOf(_Uid), "fishCannonAvatar");
					cmd.m_seatInfo[wChairID].m_iCannonLevel = m_pIUserItem[wChairID].cannonLevel;
					if(cmd.m_seatInfo[wChairID].m_iCannonLevel == 0)
						cmd.m_seatInfo[wChairID].m_iCannonLevel = 1;
					
					cmd.m_seatInfo[wChairID].m_iMaxCannonLevel = maxcannonlevel;
					cmd.m_seatInfo[wChairID].m_iCannonCost = g_vecCannonLevels.get(m_pIUserItem[wChairID].cannonLevel);
					cmd.m_seatInfo[wChairID].m_sNickName = user.getNickName(null);
				}
			}
		}
		String sData = cmd.toString();
		for(int wChairdID = 0;wChairdID < 4;wChairdID++){
			if(m_pIUserItem[wChairdID].dwUserID > 0){
				SendTableData(wChairdID,sData);
			}
		}
		this.SendHistory(_Uid);
	}
	*/
	public void Handle_onLeaveTable(int _Uid,String[] vecArg){
		
	}
}
